using System;
using System.Collections.Generic;
using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Imaging;
using Sce.PlayStation.Core.Environment;
using Sce.PlayStation.HighLevel.UI;
using Nyanimals;

namespace Nyanimals_UI
{
    public partial class NyanimalDisplay : Scene
    {
        CBaseObject displayObject;
        public NyanimalDisplay()
        {
            InitializeWidget();
        }
        
        public void SetObjectInformation(CBaseObject obj)
        {
            displayObject = obj;
            if(displayObject != null)
            {
                switch(displayObject.Type)
                {
                case ObjectTypes.Nyanimal_Object:
                    CNyanimal nyan = (CNyanimal)obj;
                    NameLabel.Text = nyan.Name;
                    
                    // hunger
                    HungerBar.Visible = true;
                    HungerLabel.Visible = true;
                    HungerPercentLabel.Visible = true;
                    
                    // running        
                    RunningPercentLabel.Visible = true;
                    RunningBar.Visible = true;
                    RunLabel.Visible = true;
                    
                    
                    // stamina
                    StaminaPercentLabel.Visible = true;
                    StaminaBar.Visible = true;
                    StaminaLabel.Visible = true;
                    
                    break;
                case ObjectTypes.Food_Object:
                    CBaseFood food = (CBaseFood)obj;
                    NameLabel.Text = obj.ToString();
                    
                    // hunger
                    HungerBar.Visible = false;
                    HungerLabel.Visible = false;
                    HungerPercentLabel.Visible = false;
                    
                    // running        
                    RunningPercentLabel.Visible = false;
                    RunningBar.Visible = false;
                    RunLabel.Visible = false;
                    
                    
                    // stamina
                    StaminaPercentLabel.Visible = false;
                    StaminaBar.Visible = false;
                    StaminaLabel.Visible = false;
                    
                    
                    break;
                };
            }
        }
        
        protected override void OnUpdate(float elapsedTime)
        {
            base.OnUpdate (elapsedTime);
            
            if(displayObject != null)
            {
                switch(displayObject.Type)
                {
                case ObjectTypes.Nyanimal_Object:
                    CNyanimal nyan = (CNyanimal)displayObject;
                    
                    // hunger
                    HungerBar.Progress = nyan.Hunger / 100.0f;
                    HungerPercentLabel.Text = (int)(nyan.Hunger) + "%";
                    
                    // running
                    RunningBar.Progress = nyan.RunningEXP / 100;
                    RunningPercentLabel.Text = (nyan.RunningEXP) + "%";
                    
                    // stamina
                    StaminaBar.Progress = nyan.RunningEXP / 100;
                    StaminaPercentLabel.Text = (nyan.RunningEXP) + "%";
                    
                    break;
                };
            }
            
        }
            
    }
}
